package lxs.tool.liberator.work.controller;

import lxs.tool.liberator.common.base.result.Response;
import lxs.tool.liberator.work.pojo.Project;
import lxs.tool.liberator.work.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("work/project")
public class ProjectController {
    @Autowired
    private ProjectService projectService;

    @GetMapping("showTable")
    public Response showTable() {
        return projectService.showTable();
    }

    @GetMapping("getById")
    public Response getById(String id) {
        return projectService.getById(id);
    }

    @PostMapping("add")
    public Response add(@RequestBody Project project) {
        return projectService.add(project);
    }

    @PostMapping("update")
    public Response update(@RequestBody Project project) {
        return projectService.update(project);
    }

    @GetMapping("getMainProject")
    public Response getMainProject() {
        return projectService.getMainProject();
    }

    @GetMapping("setMain")
    public Response setMain(String id, Integer main) {
        return projectService.setMain(id, main);
    }

    @GetMapping("generate")
    public Response generate(HttpServletResponse response) throws Exception {
        return projectService.generate(response);
    }
}
